package 编程能力入门1;

import java.util.ArrayList;
import java.util.List;

public class _11N叉树的前序遍历 {
    class Node {
        public int val;
        public List<Node> children;

        public Node() {}

        public Node(int _val) {
            val = _val;
        }

        public Node(int _val, List<Node> _children) {
            val = _val;
            children = _children;
        }
    }

    private List<Integer> res = new ArrayList<>();
    public List<Integer> preorder(Node root) {
        if(root == null) return new ArrayList<>();
        inorder(root);
        return res;
    }

    private void inorder(Node root){
        if(root == null) return;
        res.add(root.val);
        for (Node child : root.children) {
            inorder(child);
        }
    }

}
